home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Screenblankers / GBlanker / GSource / GadTools / ShowInfo.c < prev   
C/C++ Source or Header  |  1996-09-26  |  2KB  |  72 lines

  1. #include <exec/memory.h>
  2. #include <clib/exec_protos.h>
  3. #include <clib/dos_protos.h>
  4. #include <clib/intuition_protos.h>
  5. #include <pragmas/exec_pragmas.h>
  6. #include <pragmas/dos_pragmas.h>
  7. #include <pragmas/intuition_pragmas.h>
  8. #include <string.h>
  9.  
  10. extern struct Library *SysBase;
  11.  
  12. LONG main( LONG argc, STRPTR argv[] )
  13. {
  14.     struct Library *DOSBase, *IntuitionBase;
  15.  
  16.     if( argc != 2 )
  17.         return RETURN_WARN;
  18.  
  19.     DOSBase = OpenLibrary( "dos.library", 37L );
  20.     IntuitionBase = OpenLibrary( "intuition.library", 37L );
  21.  
  22.     if( DOSBase && IntuitionBase )
  23.     {
  24.         struct EasyStruct InfoReq =
  25.             { sizeof( struct EasyStruct ), 0, 0L, 0L, "Ok" };
  26.         BYTE ModuleName[64], Title[108];
  27.         STRPTR Ptr;
  28.  
  29.         strcpy( ModuleName, FilePart( argv[1] ));
  30.         if( Ptr = strstr( ModuleName, ".txt" ))
  31.             *Ptr = '\0';
  32.         strcpy( Title, ModuleName );
  33.         strcat( Title, " Information" );
  34.  
  35.         if( InfoReq.es_TextFormat = AllocVec( 1024, MEMF_CLEAR ))
  36.         {
  37.             BPTR InfoHandle;
  38.  
  39.             if( InfoHandle = Open( argv[1], MODE_OLDFILE ))
  40.             {
  41.                 LONG BytesRead;
  42.  
  43.                 BytesRead = Read( InfoHandle, InfoReq.es_TextFormat, 1024 );
  44.                 if( InfoReq.es_TextFormat[BytesRead-1] == '\n' )
  45.                     InfoReq.es_TextFormat[BytesRead-1] = '\0';
  46.                 else
  47.                     InfoReq.es_TextFormat[BytesRead] = '\0';
  48.                 Close( InfoHandle );
  49.             }
  50.             else
  51.             {
  52.                 strcpy( InfoReq.es_TextFormat,
  53.                     "No information available for module: " );
  54.                 strcat( InfoReq.es_TextFormat, ModuleName );
  55.                 strcat( InfoReq.es_TextFormat, "." );
  56.             }
  57.  
  58.             InfoReq.es_Title = Title;
  59.             EasyRequestArgs( 0L, &InfoReq, 0L, 0L );
  60.             FreeVec( InfoReq.es_TextFormat );
  61.         }
  62.     }
  63.  
  64.     if( IntuitionBase )
  65.         CloseLibrary( IntuitionBase );
  66.  
  67.     if( DOSBase )
  68.         CloseLibrary( DOSBase );
  69.  
  70.     return RETURN_OK;
  71. }
  72.